﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;


namespace sync_test.util
{
    public class Scarfold
    {

        public static string MakeOracleTable(String s)
        {

            s = s.Trim();
 
            var findTableName = Regex.Matches(s, "wf\\.\\w+", RegexOptions.IgnoreCase);
            if (findTableName.Count != 1) return "table name missing";

            // fixa rätt tabellnamn
            string oldTableName = findTableName[0].Value;
            string newTableName = oldTableName.Replace("WF.", "") + "_COPY";
            s = s.Replace(oldTableName, newTableName);
    
            // lägg till SYNCDAT
            int pos = s.LastIndexOf(")");
            if (pos == -1) return "hittar inte )";
            s = s.Insert(pos, ",SYNCDAT date\r\n");

            // lägg till SYNCDAT
            s = s + "tablespace users\r\n";
            return s;
        }

        public static string MakeMappingClass(String s)
        {
            StringBuilder sb = new StringBuilder();


            return sb.ToString();
        }

    }
}

/*
CREATE TABLE WF.TEXTER
(
  TEXTERID       INTEGER                        NOT NULL,
  TEXTERTYPID    INTEGER,
  TABELLNAMN     CHAR(35 BYTE),
  RELID          INTEGER,
  TEXT           LONG,
  KONTRAKTTYPID  NUMBER
)

*/